﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Drawing.Design;
using System.Text;
using System.Windows.Forms;
using Kugar.Core.BaseStruct;
using Kugar.Core.Collections;


namespace Kugar.UI.WinForm
{
    [Designer(typeof(CheckBoxExControlDesigner))]
    public partial class CheckBoxEx : CheckBox
    {
        public CheckBoxEx()
        {
            _controlList = new ListEx<Control>();
            _controlList.CollectionChanged += CheckBoxEx_CheckedChanged;

            InitializeComponent();

        }

        private ListEx<Control> _controlList;

        [Localizable(true)]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
        [Editor(typeof(ControlListUITypeDesign), typeof(UITypeEditor))]
        public ListEx<Control> ControlList
        {
            get { return _controlList; }
        }

        private void CheckBoxEx_CheckedChanged(object sender, EventArgs e)
        {
            if (ControlList.Count<=0)
            {
                return;
            }

            foreach (var ex in ControlList)
            {
                if (ex==null)
                {
                    return;
                }
                ex.Enabled = this.Checked;
            }
        }


    }

}
